package com.gridmobi.xrtb.routers.bidding;

import com.alibaba.fastjson.JSONObject;
import com.gridmobi.xrtb.domain.dsp.DspTrackLog;
import com.gridmobi.xrtb.dspcounter.DspCounterHandler;
import com.gridmobi.xrtb.util.RtbUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.time.LocalDateTime;
import java.util.Map;

@RestController
@RequestMapping("/")
public class LossNoticeController {
    private static final Logger logger = LoggerFactory.getLogger(LossNoticeController.class);
    private static final Logger winlog = LoggerFactory.getLogger("winlog");
    private static final Logger errorlogger = LoggerFactory.getLogger("error");
    private float defaultPrice = 4.44f;
    @Autowired
    DspCounterHandler dspCounterHandler;

    @GetMapping("dsploss")
    public void win(@RequestParam Map<String, String> args, HttpServletRequest request, HttpServletResponse response) {
        try {
            LocalDateTime now = LocalDateTime.now();

            DspTrackLog trackArgs = RtbUtil.packTrackArgs(now, args, request);

            /**
             * 计算频率
             */

            if (trackArgs != null) {
            }
        } catch (Exception e) {
            errorlogger.error("LOSSERROR", e);
        }

        winlog.warn(JSONObject.toJSONString(args));
    }
}
